package com.easy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.easy.common.bean.Product;
import com.easy.common.bean.UserAccount;
import com.easy.common.bean.UserInfo;
import com.easy.common.service.UserInfoService;
import com.easy.mapper.UserInfoMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author ASUS
* @description 针对表【user_info(用户详细信息表)】的数据库操作Service实现
* @createDate 2025-09-09 10:27:45
*/
@Service
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
    implements UserInfoService{

    @Override
    public UserInfo getUserInfoById(Long id) {
        return super.getById(id);
    }

    @Override
    public UserInfo getUserInfoByUserId(Long userId) {
        LambdaQueryWrapper<UserInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(UserInfo::getUserId, userId);
        return super.getOne(queryWrapper);
    }

    @Override
    public int addUserInfo(UserInfo userInfo) {
        return super.save(userInfo) ? 1 : 0;
    }

    @Override
    public int updateUserInfo(UserInfo userInfo) {
        return super.updateById(userInfo) ? 1 : 0;
    }

    @Override
    public int deleteUserInfo(Long id) {
        return  super.removeById(id) ? 1 : 0;
    }

    @Override
    public List<UserInfo> getAll(UserInfo userInfo) {
        LambdaQueryWrapper<UserInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(UserInfo::getRealName, userInfo.getRealName());
        return super.list(queryWrapper);
    }

    @Override
    public IPage<UserInfo> getPage(UserInfo userInfo, IPage page) {
        LambdaQueryWrapper<UserInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(UserInfo::getRealName, userInfo.getRealName());
        return super.page(page);
    }

}




